#include <windows.h>
#include <iostream>
using namespace std;


int main()
{
     HANDLE console = GetStdHandle(STD_INPUT_HANDLE);
     DWORD mode;
     GetConsoleMode(console, &mode);
     SetConsoleMode(console, mode & ~ENABLE_LINE_INPUT);

	 char answer;

start_game:
	{
		bool hasTorch = false;

		cout << endl;
		cout << "You wake up in a cave, its dark and wet." << endl;
	}

describe_wellRoom:
	{
		cout << endl;
		cout << "There is a well in the middle of the room and past that a dark stair way." << endl;
		cout << "do you:" << endl;
		cout << "[a] approach the well; or" << endl;
		cout << "[g] go up the stairs?" << endl;
		cout << ">";
	}

	cin >> answer;

	if (answer == 'a' && !hasTorch) 
	{	
		goto approach_well_without_torch;
	}

	else if (answer == 'a')
	{
		goto approach_well_with_torch;
	}

	else if (answer == 'g') 
	{
		goto go_up_stairs;
	}

	else
	{
		cout << "Your command is out of this realm of possibilities";
		goto describe_wellRoom;
	}

approach_well_without_torch:
	{
		cout << endl;
		cout << "The well seems to be the only thing illuminating the room." << endl;
		cout << "You look into it and there is a flaming torch inside" << endl;
		cout << "do you:" << endl;
		cout << "[t] take the torch; or" << endl;
		cout << "[l] leave this fiery object?" << endl;
		cout << ">";
	}

	cin >> answer;
	
	switch (answer)
	{
	case 't':
	{
		cout << endl;
		cout << "You take the torch. What lies ahead now seems more possible" << endl;
		cout << endl;
		hasTorch = true;
		goto describe_wellRoom;
	}
	case'l': 
	{
		cout << endl;
		cout << "You decide to leave the torch and look around the room for the next thing" << endl;
		cout << endl;
		hasTorch = false;
		goto describe_wellRoom;
	}

	default:
	{
		cout << "Your command is out of this realm of possibilities";
		goto approach_well_without_torch;
	}

approach_well_with_torch:
	{
		cout << endl;
		cout << "You approach the well again, but there is no longer anything of interest." << endl;
		goto describe_wellRoom;
	}

go_up_stairs:
	if (!hasTorch) 
	{
		goto go_up_stairs_without_torch;
	}

	       //0000000000111111111222222222233333333334444444444555555555566666666667777777777
go_up_stairs_with_torch:
	{
		cout << endl;
		cout << "You hold your torch in front to light the way up the stairs." << endl;
		cout << "You steadily rise up, not knowing what lies ahead...";
		cout << endl;
		cout << "...But this is another adventure for another time, congratulations" << endl;
		cout << " on comepleting the first episode of HelloWorld.";
		cout << endl;
		cout << "Please upgrade your subscription to premium to access episode 2" << endl;
		goto restart_or_quit;
	}

go_up_stairs_without_torch:
	{
		cout << endl;
		cout << "You turn back, its dark and its scary." << endl;
		goto describe_wellRoom;
	}

restart_or_quit:
	{
		cout << endl;
		cout << "[r] Restart this game." << endl;
		cout << "[q] Quit." << endl;
		cout << endl;
		cout << ">";
	}

    cin >> answer;
    
	if (answer == 'r') 
	{
		goto start_game;
	}
    
	else if (answer == 'q')
	{
		goto quit;
	}
	
	else
	{
		goto restart_or_quit;
	}

quit:
	{
		return 0;
	}

}

